package com.fun.feifun.base.auth;

import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: wukefei
 * @Date: Created in 2022/4/22 16:12
 * @Description:
 * @Version: 1.0
 *
 */
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
	/**
	 * 注册Sa-Token 的拦截器，打开注解式鉴权功能
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// todo 注册注解拦截器 可以用来存放允许放行的路径
		// 除了/user/doLogin 可以放行  其余的操作都需要进行登录之后才可以进行操作
		registry.addInterceptor(new SaAnnotationInterceptor())
				.addPathPatterns("/**")
				.excludePathPatterns("sys/auth/login")
				.excludePathPatterns("business/business-order/placeOrderOutside")
				.excludePathPatterns("sys/user/*");
	}

}
